<html lang="en-US">

<head>
    
<title>Go - 花落雨忧</title>

<meta property="og:title" content="Go - 花落雨忧">



    



    






<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">

<link rel="shortcut icon" href="https://www.lican.asia/logo/logo.png" type="image/x-icon" />


<link href="/tags/go/index.xml" rel="alternate" type="application/rss+xml" title="花落雨忧" />


<link rel="stylesheet" href="/css/style.min.css" />

<link rel="stylesheet" href="/css/reset.min.css" />




<script src="https://www.lican.asia/js/highlight.min.js"></script>

<script>
hljs.configure({ ignoreUnescapedHTML: true })
hljs.highlightAll();
</script>


<script src="https://www.lican.asia/js/jquery.min.js"></script>




<link href="https://www.lican.asia/css/hugo-code.min.css" rel="stylesheet" />



</head>

<body id="period" class="home blog">
    <a class="skip-content" href="#main">Press "Enter" to skip to content</a>
    <div id="overflow-container" class="overflow-container">
        <header class="site-header" id="site-header" role="banner">
    <div class="max-width">
        <div id="title-container" class="title-container">
            <div id="site-title" class="site-title"><a href="/">花落雨忧</a></div>
            <p class="tagline">思所及 力所行 方为真.</p>
        </div>
        
        <div id="menu-primary-container" class="menu-primary-container">
            <div class="icon-container">
            </div>
            <div id="menu-primary" class="menu-container menu-primary" role="navigation">
                <nav class="menu">
                    <ul id="menu-primary-items" class="menu-primary-items">
                        
                        
                        <li id="menu-item-0"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/posts" aria-current="page" tabindex="0">首页</a></li>
                        
                        <li id="menu-item-1"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/tech/" aria-current="page" tabindex="1">技术文档</a></li>
                        
                        <li id="menu-item-2"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/article/" aria-current="page" tabindex="2">文章</a></li>
                        
                        <li id="menu-item-3"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/project/" aria-current="page" tabindex="3">项目</a></li>
                        
                        <li id="menu-item-4"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/about/" aria-current="page" tabindex="4">关于</a></li>
                        
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</header>

        <div id="primary-container" class="primary-container">
            <div class="max-width">
                <section id="main" class="main" role="main">
    <div id="loop-container" class="loop-container">
        
        
        
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/talk/2019-06-16-defer-loss/">Go1.12 defer 会有性能损耗，尽量不要用？</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/06/16</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>上个月在 @polaris @轩脉刃 的全栈技术群里看到一个小伙伴问 “说 defer 在栈退出时执行，会有性能损耗，尽量不要用，这个怎么解？”。
恰好前段时间 …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/defer/2019-05-27-defer/">深入理解 Go defer</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/05/27</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>在上一章节 《深入理解 Go panic and recover》中，我们发现了 defer 与其关联性极大，还是觉得非常有必要深入一下。希望通过本章节大家可以 …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/panic/2019-05-21-panic-and-recover/">深入理解 Go panic and recover</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/05/21</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>作为一个 gophper，我相信你对于 panic 和 recover 肯定不陌生，但是你有没有想过。当我们执行了这两条语句之后。底层到底发生了什么事呢？前几天 …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/talk/2019-05-20-stack-heap/">我要在栈上。不，你应该在堆上</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/05/20</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>我们在写代码的时候，有时候会想这个变量到底分配到哪里了？这时候可能会有人说，在栈上，在堆上。信我准没错&hellip;
但从结果上来讲你还是一知半解，这可不行， …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/map/2019-04-07-why-map-no-order/">为什么遍历 Go map 是无序的</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/04/07</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>有的小伙伴没留意过 Go map 输出顺序，以为它是稳定的有序的；有的小伙伴知道是无序的，但却不知道为什么？有的却理解错误？今天我们将通过本文，揭开 for …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/talk/2019-03-31-go-ins/">简单围观一下有趣的 //go: 指令</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/03/31</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>前言 如果你平时有翻看源码的习惯，你肯定会发现。咦，怎么有的方法上面总是写着 //go: 这类指令呢。他们到底是干嘛用的？
今天我们一同揭开他们的面纱，我将简单 …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/map/2019-03-24-map-assign/">深入理解 Go map：赋值和扩容迁移</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/03/24</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>概要 在 上一章节 中，数据结构小节里讲解了大量基础字段，可能你会疑惑需要 #&amp;（！……#（！￥！ 来干嘛？接下来我们一起简单了解一下基础概念。再开始研 …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/map/2019-03-05-map-access/">深入理解 Go map：初始化和访问元素</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/03/05</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>从本文开始咱们一起探索 Go map 里面的奥妙吧，看看它的内在是怎么构成的，又分别有什么值得留意的地方？
第一篇将探讨初始化和访问元素相关板块，咱们带着疑问去 …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/talk/2019-02-17-for-loop-json-unmarshal/">for-loop 与 json.Unmarshal 性能分析概要</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/02/17</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>在项目中，常常会遇到循环交换赋值的数据处理场景，尤其是 RPC，数据交互格式要转为 Protobuf，赋值是无法避免的。一般会有如下几种做法：
for for …</p>
                        
                    </div>
            </article>
        </div>
        
        <div
            class="post-6033 post type-post status-publish format-standard hentry category-php8 category-php-usage category-notes tag-match tag-match-expressionswitch tag-php-8 tag-php8 entry">
            <article>
                <div class="post-container">
                    <div class="post-header">
                        <h2 class="post-title">
                            <a href="/posts/posts/go/talk/2019-01-20-control-goroutine/">来，控制一下 goroutine 的并发数量</a>
                        </h2>
                        <div class="post-byline">Published on
                            <a class="date" href="javascript:;">2019/01/20</a>
                            
                            
                            
                            By 
                            <a class="author" href="javascript:;">煎鱼</a></div>
                            
                    </div>
                    <div class="post-content">
                        
                        
                        
                        
                        <p>问题 func main() { userCount := math.MaxInt64 for i := 0; i &lt; userCount; i++ { …</p>
                        
                    </div>
            </article>
        </div>
        

    </div>


    <nav class="navigation pagination" role="navigation" aria-label="Posts">
        <h2 class="screen-reader-text">Posts navigation</h2>
        <div class="nav-links">
            
            <a class="prev page-numbers" href="/tags/go/page/10/">Previous</a>
            
            
            
            <a class="page-numbers" href="/tags/go/">1</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/2/">2</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/3/">3</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/4/">4</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/5/">5</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/6/">6</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/7/">7</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/8/">8</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/9/">9</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/10/">10</a>
            
            
            
            <span aria-current="page" class="page-numbers current">11</span>
            
            
            
            
            <a class="page-numbers" href="/tags/go/page/12/">12</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/13/">13</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/14/">14</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/15/">15</a>
            
            
            
            <a class="page-numbers" href="/tags/go/page/16/">16</a>
            
            
            
            <a class="next page-numbers" href="/tags/go/page/12/">Next</a>
            
        </div>
    </nav>
</section> 
<script src="https://readmore.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
    const btw = new BTWPlugin();
    btw.init({
        id: 'container',
        blogId: '33573-1732499652133-368',
        name: '花落雨忧',
        qrcode: 'https://www.lican.site/wechat/lican.png',
        keyword: '花落雨忧',
    });
</script>


                
                <aside class="sidebar sidebar-primary" id="sidebar-primary" role="complementary">
    <h1 class="screen-reader-text">Sidebar</h1>
    

    
    
    <section id="text-2" class="widget widget_text">
        <div class="textwidget">
            
            <div id="profile">
                <div id="profile_picture"><img src="https://www.lican.asia/logo/logo.png"></div>
                <div id="profile_intro">
                    <p><span class="name">Lican</span></p>
                    <p class="intro">全栈开发者，爱好造轮子。</p>
                </div>
            </div>
            
            <p>
                <script type="text/javascript">
                    (function ($) {
                        $(document).ready(function () {
                            var menuPrimaryContainer = $('#menu-primary-container');
                            var profile = $('#text-2');
                            $('#toggle-navigation').click(function () {
                                if (menuPrimaryContainer.hasClass('open')) {
                                    profile.removeClass('open');
                                } else {
                                    profile.addClass('open');
                                }
                            });
                        });
                    })(jQuery);
                </script>
            </p>
        </div>
    </section>
    
    
    
    
    
    <section id="text-5" class="widget widget_text">
        <h2 class="widget-title">开源项目</h2>
        <div class="textwidget">
            <div id="projects" style="line-height: 22px;">
                
                <a href="https://github.com/idoubi/gonews"
                    target="_blank">gonews</a>: &nbsp;Daily news for golang<br>
                
                <a href="https://github.com/idoubi/sql2struct"
                    target="_blank">sql2struct</a>: &nbsp;Generate go struct according to SQL<br>
                
                <a href="https://github.com/idoubi/goz"
                    target="_blank">goz</a>: &nbsp;Request library used in golang<br>
                
        </div>
    </section>
    
    

    
    
    
    
    <section id="qrcode" class="widget widget_media_image">
        <h2 class="widget-title">微信公众号</h2>
        <img width="258" height="258"
            src="https://www.lican.asia/wechat/lican.png"
            class="image wp-image-5514  attachment-full size-full" alt=""
            style="max-width: 100%; height: auto;"
            sizes="(max-width: 258px) 100vw, 258px">
    </section>
    
    

    
    
    

    
    
    

    
    
    
    
</aside>
            </div>
        </div>

        <footer id="site-footer" class="site-footer" role="contentinfo">
    <div class="max-width">
    </div>
    <div class="footer">
        <div id="footercontent">
            © lican.asia All rights reserved<br/>
            Built with Hugo Theme <a href="https://github.com/idoubi/hugo-theme-period" target="_blank">Period</a>
        </div>
    </div>
</footer>

<script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e8351b6d4626d5881d439ea1f6184baa";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
</script>
    
    
    </div>
    
</body>

</html>